#ifndef _ZMYSQL_H__
#define _ZMYSQL_H__
#include <mysql/mysql.h>
typedef unsigned long long ulonglong;
namespace mysqlcpp {
class ZMysql {
	public:
	    ZMysql();
	    ZMysql(const char* host, unsigned short port, const char* db, const char* user, const char* password);
	    virtual ~ZMysql();

	    ulonglong affected_rows();

	    bool connect();

	    virtual bool connect(const char* host, unsigned short port, 
	    	const char* db, const char* user, const char* password);
	    bool connected() const {return is_connected_;}	    
	    void disconnect();	    
	    int errnum() {return mysql_errno(&mysql_);}
	    bool ping()	{return !mysql_ping(&mysql_);}
	    bool set_option(mysql_option moption, const void* arg = 0) {		
			return !mysql_options(&mysql_, moption, static_cast<const char*>(arg));
		}

	    bool execute(const char* qstr, unsigned long strsize);
	    MYSQL_ROW fetch_row();
	    void free_result();
	    int num_fields()const;
	    ulonglong num_rows()const;	    
	   
	    bool shutdown();
	    bool store_result();
	    bool use_result();


	private:
		MYSQL mysql_;
		bool is_connected_;
		MYSQL_RES *res_;
		MYSQL_ROW row_;
		MYSQL_FIELD *fd_;
		char host_[17];
		char user_[50];
		char password_[256];
		char db_[256];
		unsigned short port_;
};

} // end namespace  mysqlcpp

#endif // ifndef _ZMYSQL_H__
